import unittest
import requests

from day_01_03 import TpLogin


class TextLogin(unittest.TestCase):
    ser = None

    @classmethod
    def setUpClass(cls) -> None:
        cls.ser = requests.Session()

    @classmethod
    def doClassCleanups(cls) -> None:
        cls.ser.close()

    def setUp(self) -> None:
        TpLogin.login_v(self.ser)

    def test01_login_ok(self):
        login_data1 = {"username": "17671055841",
                       "password": "a123456789a",
                       "verify_code": "8888"}

        res = TpLogin.login_ok(login_data1, self.ser)
        self.assertEqual(1, res.json().get("status"))
        self.assertIn("登陆成功", res.json().get("msg"))
        print(res.json())

    def test02_mobile_no(self):
        login_data1 = {"username": "17671055544",
                       "password": "a123456789a",
                       "verify_code": "8888"}
        res = TpLogin.login_ok(login_data1,self.ser)
        self.assertEqual(-1, res.json().get("status"))
        self.assertIn("不存在", res.json().get("msg"))
        print(res.json())

    def test03_pass_no(self):
        login_data1 = {"username": "17671055544",
                       "password": "a123456789a",
                       "verify_code": "8888"}
        res = TpLogin.login_ok(login_data1,self.ser)
        self.assertEqual(-1, res.json().get("status"))
        self.assertIn("不存在", res.json().get("msg"))
        print(res.json())
